package com.lzy.cloud.order.service.impl;

import com.lzy.cloud.order.dtos.OrderRefundPicDto;
import com.lzy.cloud.order.entity.OrderRefundPic;
import com.lzy.cloud.order.mapper.OrderRefundPicMapperExt;
import com.lzy.cloud.order.service.OrderRefundPicService;
import com.lzy.framework.core.utils.DozerUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description: 订单退换货图片信息
 * @Author:   gyl
 * @Date:     2018/7/10 20:14
 */
@Service
public class OrderRefundPicServiceImpl implements OrderRefundPicService {

    @Autowired
    private OrderRefundPicMapperExt orderRefundPicMapperExt;

    @Override
    public List<OrderRefundPicDto> queryList(OrderRefundPicDto orderRefundPicDto) {
        return orderRefundPicMapperExt.queryList(orderRefundPicDto);
    }

    @Override
    public Long create(OrderRefundPicDto orderRefundPicDto) {
        OrderRefundPic orderRefundPic = DozerUtils.map(orderRefundPicDto, OrderRefundPic.class);
        return orderRefundPicMapperExt.insertSelective(orderRefundPic)>0 ? orderRefundPic.getId() : 0;
    }

    @Override
    public void deleteByRefundId(Long refundId) {
        orderRefundPicMapperExt.deleteByRefundId(refundId);
    }

    @Override
    public Boolean update(OrderRefundPicDto orderRefundPicDto) {
        return orderRefundPicMapperExt.updateByPrimaryKeySelective(DozerUtils.map(orderRefundPicDto, OrderRefundPic.class)) > 0;
    }
}
